// packageJ/anytime_service/my/skill_manage/skill_manage.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

    language: "",
    page:1,
    last_page:1,
    active:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    let language = wx.getStorageSync('langIndex');
    this.setData({
      'language': language.en
    });

    this.getData();
  },
  tab_handle(e){
    this.setData({active:e.detail.name});
    this.getData()
  },
  getData(page = 1){
    let json = {
      page,
      state:this.data.active
    }
    app._getNetWork({
      url:app.getNetAddresss('plugin.be-within-call.frontend.shi-fu.ability'),
      data:json,
      success:resdata=>{
        let {result,data,msg} = resdata.data;
        if(result){

          this.page = data.current_page
          this.last_page = data.last_page;
          if(page == 1){
            this.setData({
              list:data.data
            })
          }else{
            this.setData({
              list:this.data.list.concat(data.data)
            })
          }


        }else {
          app.tips(msg);
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  submit(e) {
    if (e.currentTarget.dataset.i == 1) {
      let aid = e.currentTarget.dataset.aid;
      if(e.currentTarget.dataset.status==-1){
        wx.navigateTo({
          url: '/packageJ/anytime_service/my/skill_release/skill_release?type=2&aid='+aid,
        })
      }else{
        wx.navigateTo({
          url: '/packageJ/anytime_service/my/skill_release/skill_release?type=1&aid='+aid,
        })

      }
    } else {
      wx.navigateTo({
        url: '/packageJ/anytime_service/my/skill_release/skill_release?type=2',
      })
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if(this.data.page>=this.data.last_page){
      return;
    }
    let page = this.data.page + 1;
    this.getData(page);
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})